import { trans } from '@utils/common'
import { post, get, postL, getL } from '@utils/http'
import { SERVE_URL } from '@utils/config'
export default {
    apis: {
        //================平台================
        PLATFORM_DETAIL: SERVE_URL + 'apiExp/merchant/platform/detail',
        PLATFORM_UPDATE: SERVE_URL + 'apiExp/merchant/platform/saveOrUpdate', //修改平台管理信息
        LEASEPERIODSWITCH_LIST: SERVE_URL + 'apiExp/goods/leasePeriodSwitch/list',
        LEASEPERIODSWITCH_LISTPROFITRATE: SERVE_URL + 'apiExp/businessOperations/leaseRate/leasePageQuery', //租赁周期开关日志
        LEASEPERIODSWITCH_ENABLE: SERVE_URL + 'apiExp/goods/leasePeriodSwitch/enable', //启用租期
        LEASEPERIODSWITCH_CLOSE: SERVE_URL + 'apiExp/goods/leasePeriodSwitch/close', //关闭租期
        LEASEPERIODSWITCH_GOOD: SERVE_URL + 'apiExp/manager/bfqzLeasePeriodSwitch/getAvailableLeasePeriodByGoodsId',

        //===============用户===============
        USER_LIST: SERVE_URL + 'apiExp/member/user/pageQuery', //用户管理列表
        USER_DISABLE: SERVE_URL + 'apiExp/member/user/disable', //用户管理禁用
        USER_ENABLE: SERVE_URL + 'apiExp/member/user/enable', //用户管理启用
        USER_REMOVE: SERVE_URL + 'apiExp/member/user/delete', //用户管理删除
        USER_INFO_ALL: SERVE_URL + 'apiExp/manager/userCenter/userById',

        //===============商品分类===================
        CATEGORY_LIST: SERVE_URL + 'apiExp/goods/category/queryList', //查询所有商品分类
        CATEGORY_TREE: SERVE_URL + 'apiExp/goods/category/dropdownBoxList', //商品分类下拉框,有最上级
        CATEGORY_DELETE: SERVE_URL + 'apiExp/goods/category/deleteById', //删除商品分类
        CATEGORY_EDIT: SERVE_URL + 'apiExp/goods/category/updateById', //修改商品分类
        CATEGORY_ADD: SERVE_URL + 'apiExp/goods/category/add', //添加商品分类
        CATEGORY_CASCADER: SERVE_URL + 'apiExp/goods/category/dropdownBoxList', //商品分类下拉框,没有最上级

        //===============建议======================
        SUGGESTION_LIST: SERVE_URL + 'apiExp/member/suggestions/pageQuery',

        //================订单=====================
        ORDER_LIST: SERVE_URL + 'apiExp/order/pageQuery', //订单分页
        ORDER_EXPORT: SERVE_URL + 'apiExp/order/exportOrder', //订单导出
        OVERDU_ORDER_EXPORT: SERVE_URL + 'apiExp/order/exportOverdueOrder', //订单导出
        ORDER_SON_LIST: SERVE_URL + 'apiExp/manager/bfqzOrderDetail/list',
        ORDER_AUDIT: SERVE_URL + 'apiExp/order/audit', //审核是否通过
        ORDER_MODIFYADDRESS: SERVE_URL + 'apiExp/order/modifyAddress', //修改收货地址
        CANCEL_ORDER_NEW: SERVE_URL + 'apiExp/order/cancelOrder', //审核不通过/取消订单
        ORDER_MODIFY_LOGISTIC: SERVE_URL + 'apiExp/order/modifyLogistic', //修改物流单号
        ORDER_CONFIRM_SETTLE: SERVE_URL + 'apiExp/order/confirmSettle', //商户确认还款/完结订单

        CANCEL_ORDER_DETAIL: SERVE_URL + 'apiExp/order/detail', //订单详情

        ORDER_DELIVER: SERVE_URL + 'apiExp/order/delivery',
        ORDER_DETAIL_UPDATE: SERVE_URL + 'apiExp/manager/bfqzOrderDetail/update',
        // ORDER_DETAIL_QUERYTRACK: SERVE_URL + 'apiExp/manager/logistics/queryTrack', //查看物流-快100
        ORDER_DETAIL_QUERYTRACK: SERVE_URL + 'apiExp/logistics/info/getLogisticsNode', //查看物流-顺丰
        ORDER_DELIVERY: SERVE_URL + 'apiExp/order/delivery', //确认发货
        ORDER_DELIVERY_ORDER: SERVE_URL + 'apiExp/order/deliverOrder', //确认发货
        ORDER_GET_DETAIL: SERVE_URL + 'apiExp/order/payDetail', //订单已支付详情
        ORDER_RENT_DETAIL: SERVE_URL + 'apiExp/order/rentDetail', //还租详情
        ORDER_DEDUCT: SERVE_URL + 'apiExp/order/deduct', //申请扣除押金
        ORDER_REFUND: SERVE_URL + 'apiExp/order/refundDeposit', //退还押金
        ORDER_UNFREEZE: SERVE_URL + 'apiExp/order/freezeDeposit', //支付宝解冻
        ORDER_REDUCE_DEPOSIT: SERVE_URL + 'apiExp/order/reduceDeposit', //减免押金
        ORDER_REDUCE_OVER: SERVE_URL + 'apiExp/order/reduceOver', //减免滞纳金

        //================结算单===================
        SETTLE_BY_ORDER: SERVE_URL + 'apiExp/manager/bfqzOrderDetail/selectSettleByOrderId',
        //=================合同===================
        CONTRACT_BY_ORDER: SERVE_URL + 'apiExp/manager/bfqzContract/getObjectByOrderId',

        //=================风控信息=================
        RISK_CONTROL: SERVE_URL + 'apiExp/risk/oldAttachment',
        NEW_RISK_CONTROL: SERVE_URL + 'apiExp/risk/creditRisk', //信贷风险报告
        NEW_RISK_CONTROL2: SERVE_URL + 'apiExp/risk/riskOfCourt', //个人法律信息
        NEW_RISK_CONTROL3: SERVE_URL + 'apiExp/risk/newAttachment', //全景雷达
        RISK_ACCOUNT_PAY: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/doRiskPay', //风控查询扣费
        RISK_ACCOUNT_BALANCE: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/pageOrderBalance', //商户资金账户流水分页查询（平台端）
        RISK_ACCOUNT_BALANCE_COMPANY: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/pageSomeCompanyOrderBalance', //商户余额-流水明细 分页查询（商户端）
        RISK_ACCOUNT_TYPE: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/listRiskType', //获取风控类型列表
        COMPANY_GET_RISK: SERVE_URL + 'apiExp/manager/sysCompany/getRisk', //新风控查询
        RISK_ACCOUNT_EXPORT: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/exportFashionable', //导出1
        RISK_ACCOUNT_EXPORT2: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/exportFashionable2', //导出2
        RISK_ACCOUNT_CHECK: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/checkRiskBalance', //风控账户金额校验

        //=================C端首页活动==============
        HOME_ACTIVITY_ALL: SERVE_URL + 'apiExp/manager/bfqzHome/listAll',
        HOME_ACTIVITY_LIST: SERVE_URL + 'apiExp/manager/bfqzHome/list',
        HOME_ACTIVITY_UPDATE: SERVE_URL + 'apiExp/manager/bfqzHome/update',
        HOME_ACTIVITY_DELETE: SERVE_URL + 'apiExp/manager/bfqzHome/remove',
        HOME_ACTIVITY_GOODS: SERVE_URL + 'apiExp/manager/bfqzGoods/listByHomeId',
        HOME_ACTIVITY_GOODS_UPDATE: SERVE_URL + 'apiExp/manager/bfqzGoods/updateGoodsHome',
        HOME_ACTIVITY_SUBS: SERVE_URL + 'apiExp/manager/bfqzHomeActive/listAll',

        //=================商品管理=================
        GOODS_ALL: SERVE_URL + 'apiExp/manager/bfqzGoods/listAll',
        GOODS_LIST: SERVE_URL + 'apiExp/goods/pageQuery', //商品列表
        GOODS_EDIT: SERVE_URL + 'apiExp/goods/editGoods', //修改商品
        GOODS_ADD: SERVE_URL + 'apiExp/goods/addGoods', //添加商品
        GOODS_DELETE: SERVE_URL + 'apiExp/goods/deleteGoods', //删除商品
        GOODS_DETAIL_LIST_ALL: SERVE_URL + 'apiExp/goods/detailGoods',
        GOODS_PUT_SHELVES: SERVE_URL + 'apiExp/goods/audit/putShelves', //上架
        GOODS_SET_SUBMIT: SERVE_URL + 'apiExp/goods/audit/submitReviewApplication', //提交上架审核
        GOODS_DOWN_SHELVES: SERVE_URL + 'apiExp/goods/audit/downShelves', //下架
        GOODS_REFUSE_PUT_SHELVES: SERVE_URL + 'apiExp/goods/audit/refusePutShelves', //拒绝上架

        //===============优惠券==================
        COUPON_ALL: SERVE_URL + 'apiExp/manager/bfqzCoupon/listAll',
        COUPON_LIST: SERVE_URL + 'apiExp/manager/bfqzCoupon/list',
        COUPON_EDIT: SERVE_URL + 'apiExp/manager/bfqzCoupon/update',
        COUPON_DELETE: SERVE_URL + 'apiExp/manager/bfqzCoupon/remove',

        //==============账单信息==============
        BILL_INFO: SERVE_URL + 'apiExp/manager/bfqzPay/getObj',
        BILL_LIST: SERVE_URL + 'apiExp/wealth/order/pageQuery',
        BILL_EXPORT: SERVE_URL + 'apiExp/manager/bfqzOrder/exportlistAccount',
    },

    async getDetail(param) {
        const res = await trans(get(this.apis.ORDER_GET_DETAIL, param));
        return res.data;
    },

    async rentDetail(param) {
        const res = await trans(get(this.apis.ORDER_RENT_DETAIL, param));
        return res.data;
    },
    async getDeduct(param) {
        const res = await trans(post(this.apis.ORDER_DEDUCT, param));
        return res;
    },
    async reduceDeposit(param) {
        //减免押金
        const res = await trans(post(this.apis.ORDER_REDUCE_DEPOSIT, param));
        return res.success;
    },
    async reduceOver(param) {
        //减免滞纳金
        const res = await trans(post(this.apis.ORDER_REDUCE_OVER, param));
        return res.success;
    },
    async depRefund(param) {
        const res = await trans(post(this.apis.ORDER_REFUND, param));
        return res;
    },
    async zfbUnfreeze(param) {
        const res = await trans(post(this.apis.ORDER_UNFREEZE, param));
        return res;
    },

    async platformDetail() {
        const res = await trans(post(this.apis.PLATFORM_DETAIL));
        return res.data;
    },

    async platformEdit(param) {
        const res = await trans(postL(this.apis.PLATFORM_UPDATE, param));
        return res.success;
    },
    async LeasePeriodSwitchList(param) {
        let res = await trans(postL(this.apis.LEASEPERIODSWITCH_LIST, param));

        return res.data;
    },
    async LeasePeriodSwitchListProfitRate(pageNo, pageSize = 20, param) {
        const res = await trans(
            postL(this.apis.LEASEPERIODSWITCH_LISTPROFITRATE, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },
    async LeasePeriodSwitchEnable(param) {
        const res = await trans(getL(this.apis.LEASEPERIODSWITCH_ENABLE, param));
        return res;
    },
    async LeasePeriodSwitchClose(param) {
        const res = await trans(getL(this.apis.LEASEPERIODSWITCH_CLOSE, param));
        return res;
    },
    async LeasePeriodSwitchGood(param) {
        const res = await trans(postL(this.apis.LEASEPERIODSWITCH_GOOD, param));
        return res.data;
    },
    async users(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.USER_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    async userInfoAll(id) {
        const res = await trans(post(this.apis.USER_INFO_ALL, { id }));
        return res.data;
    },

    async userDisable(param) {
        const res = await trans(getL(this.apis.USER_DISABLE, param));
        return res.success;
    },
    async userEnable(param) {
        const res = await trans(getL(this.apis.USER_ENABLE, param));
        return res.success;
    },

    async userRemove(userId) {
        const res = await trans(getL(this.apis.USER_REMOVE, { userId }));
        return res.success;
    },

    async categorys(param) {
        const res = await trans(post(this.apis.CATEGORY_LIST, param));
        if (res.data) {
            res.data = res.data.filter(item => item.goodsCategoryId != -1);
        }
        return res.data;
    },

    async categoryTree(param) {
        const res = await trans(post(this.apis.CATEGORY_TREE, param));
        return res.data;
    },

    async categoryCascader(param) {
        const res = await trans(post(this.apis.CATEGORY_CASCADER, param));
        return res.data[0].children;
    },

    async categoryDelete(param) {
        const res = await trans(postL(this.apis.CATEGORY_DELETE, param));
        return res.success;
    },

    async categoryEdit(param) {
        const res = await trans(postL(this.apis.CATEGORY_EDIT, param));
        return res.data;
    },
    async categoryAdd(param) {
        const res = await trans(postL(this.apis.CATEGORY_ADD, param));
        return res.data;
    },

    async suggestions(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.SUGGESTION_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize, orderByColumn: 'createTime', orderDirection: 'desc' },
            })
        );
        return res;
    },

    async orders(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.ORDER_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    async orderAudit(param) {
        const res = await trans(postL(this.apis.ORDER_AUDIT, param));
        return res.success;
    },
    async orderModifyAddress(param) {
        const res = await trans(postL(this.apis.ORDER_MODIFYADDRESS, param));
        return res.success;
    },
    async orderModifyLogistic(param) {
        const res = await trans(postL(this.apis.ORDER_MODIFY_LOGISTIC, param));
        return res.success;
    },
    async cancelOrderNew(param) {
        const res = await trans(postL(this.apis.CANCEL_ORDER_NEW, param));
        return res.success;
    },
    async orderConfirmSettle(param) {
        const res = await trans(postL(this.apis.ORDER_CONFIRM_SETTLE, param));
        return res.success;
    },
    async cancelOrderDetail(param) {
        const res = await trans(postL(this.apis.CANCEL_ORDER_DETAIL, param));
        return res;
    },

    async orderDetailUpdate(param) {
        const res = await trans(postL(this.apis.ORDER_DETAIL_UPDATE, param));
        return res.success;
    },

    async orderDetailQueryTrack(param) {
        const res = await trans(get(this.apis.ORDER_DETAIL_QUERYTRACK, param));
        return res.data;
    },

    async orderDetailDelivery(param) {
        const res = await trans(get(this.apis.ORDER_DELIVERY, param));
        return res.data;
    },
    async deliverOrder(param) {
        const res = await trans(get(this.apis.ORDER_DELIVERY_ORDER, param));
        return res.data;
    },

    async deliver(param) {
        const res = await trans(postL(this.apis.ORDER_DELIVER, param));
        return res.success;
    },

    async orderExport(param) {
        const res = await trans(
            postL(this.apis.ORDER_EXPORT, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },
    async overduOrderExport(param) {
        const res = await trans(
            postL(this.apis.OVERDU_ORDER_EXPORT, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async orderSons(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.ORDER_SON_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async settleByOrder(orderId) {
        const res = await trans(post(this.apis.SETTLE_BY_ORDER, { orderId }));
        return res.data;
    },

    async contractByOrder(orderId) {
        const res = await trans(post(this.apis.CONTRACT_BY_ORDER, { orderId }));
        return res.data;
    },

    async riskControl(param) {
        const res = await trans(postL(this.apis.RISK_CONTROL, param));
        return res.data;
    },

    async riskAccountCheck(param) {
        const res = await trans(post(this.apis.RISK_ACCOUNT_CHECK, param));
        return res;
    },

    async newRiskControl(param) {
        const res = await trans(post(this.apis.NEW_RISK_CONTROL, param));
        return res;
    },

    async newRiskControl2(param) {
        const res = await trans(post(this.apis.NEW_RISK_CONTROL2, param));
        return res;
    },

    async newRiskControl3(param) {
        const res = await trans(post(this.apis.NEW_RISK_CONTROL3, param));
        return res;
    },

    async riskAccountPay(param) {
        const res = await trans(post(this.apis.RISK_ACCOUNT_PAY, param));
        return res;
    },
    async riskAccountBalance(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.RISK_ACCOUNT_BALANCE, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async riskAccountBalanceCompany(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.RISK_ACCOUNT_BALANCE_COMPANY, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async riskCompany(param) {
        const res = await trans(postL(this.apis.COMPANY_GET_RISK, param));
        return res;
    },

    async riskAccountExport(param) {
        const res = await trans(
            postL(this.apis.RISK_ACCOUNT_EXPORT, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async riskAccountExport2(param) {
        const res = await trans(
            postL(this.apis.RISK_ACCOUNT_EXPORT2, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async riskAccountType(param) {
        const res = await trans(postL(this.apis.RISK_ACCOUNT_TYPE, param));
        return res.data;
    },

    async homeActivityAll(param) {
        const res = await trans(post(this.apis.HOME_ACTIVITY_ALL, param));
        return res.data;
    },

    async homeActivitys(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.HOME_ACTIVITY_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async homeActivityEdit(param) {
        const res = await trans(postL(this.apis.HOME_ACTIVITY_UPDATE, param));
        return res.success;
    },

    async homeActivityDelete(ids) {
        const res = await trans(getL(this.apis.HOME_ACTIVITY_DELETE, { ids }));
        return res.success;
    },

    async homeActivityGoodss(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.HOME_ACTIVITY_GOODS, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async homeActivityGoodsGupdate(param) {
        const res = await trans(postL(this.apis.HOME_ACTIVITY_GOODS_UPDATE, param));
        return res.success;
    },

    async homeActivitySubs(param) {
        const res = await trans(post(this.apis.HOME_ACTIVITY_SUBS, param));
        return res.data;
    },

    async goodsAll(param) {
        const res = await trans(post(this.apis.GOODS_ALL, param));
        return res.data;
    },

    async goodss(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.GOODS_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    async goodsEdit(param) {
        const res = await trans(postL(this.apis.GOODS_EDIT, param));
        return res.success;
    },
    async goodsAdd(param) {
        const res = await trans(postL(this.apis.GOODS_ADD, param));
        return res.success;
    },

    async goodsDelete(goodsId) {
        const res = await trans(getL(this.apis.GOODS_DELETE, { goodsId }));
        return res.success;
    },
    // 上架
    async putShelves(param) {
        const res = await trans(postL(this.apis.GOODS_PUT_SHELVES, param));
        return res;
    },
    // 下架
    async downShelves(param) {
        const res = await trans(postL(this.apis.GOODS_DOWN_SHELVES, param));
        return res;
    },
    // 拒绝上架
    async refusePutShelves(param) {
        const res = await trans(postL(this.apis.GOODS_REFUSE_PUT_SHELVES, param));
        return res;
    },
    // 提交上架审核
    async goodsSubmit(param) {
        const res = await trans(postL(this.apis.GOODS_SET_SUBMIT, param));
        return res;
    },

    async goodsDetailAll(param) {
        const res = await trans(get(this.apis.GOODS_DETAIL_LIST_ALL, param));
        return res.data;
    },

    async couponAll(param) {
        const res = await trans(post(this.apis.COUPON_ALL, param));
        return res.data;
    },
    async coupons(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.COUPON_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async couponEdit(param) {
        const res = await trans(postL(this.apis.COUPON_EDIT, param));
        return res.success;
    },

    async couponDelete(ids) {
        const res = await trans(getL(this.apis.COUPON_DELETE, { ids }));
        return res.success;
    },
    async billInfo() {
        const res = await trans(post(this.apis.BILL_INFO));
        return res.data;
    },
    async billList(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.BILL_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize, orderByColumn: 'rentStartTime', orderDirection: 'desc' },
            })
        );
        return res;
    },
    async billExport(param) {
        const res = await trans(
            postL(this.apis.BILL_EXPORT, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },
    async getLogByOrderId(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(SERVE_URL + 'apiExp/order/getLogByOrderId', {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },
};
